﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace PokemonBattle.PokemonData.Util
{
    public static class StringHelper
    {
        /// <summary>
        /// 字符串转int
        /// </summary>
        public static int ToInt(this string s, int def = 0)
        {
            int i = def;
            int.TryParse(s, out i);
            return i;
        }

        /// <summary>
        /// 字符串转long
        /// </summary>
        public static long ToLong(this string s, long def = 0)
        {
            long i = def;
            long.TryParse(s, out i);
            return i;
        }

        /// <summary>
        /// 字符串转double
        /// </summary>
        public static double ToDouble(this string s, double def = 0)
        {
            double i = def;
            double.TryParse(s, out i);
            return i;
        }
    }
}